package com.boundless.helmet.utils;

import android.content.Context;
import android.util.Log;

import com.boundless.helmet.app.MyApplication;

public class SpUtils {

    private static final String TAG = "SpUtils";
    private static final String KEY_LIGHT = "KEY_LIGHT";

    //获取屏幕亮度
    public static int get_key_light() {
        int light = SpUtils.getConfig(KEY_LIGHT, 1);
        Log.d(TAG, "get_key_light: " + light);
        return light;
    }


    //设置屏幕亮度
    public static void set_key_light(int value) {
        SpUtils.putConfig(KEY_LIGHT, value);
    }


    public static void putConfig(String key, int value) {
        MyApplication.getInstance().getSharedPreferences("config", Context.MODE_PRIVATE).edit().putInt(key, value).apply();
    }

    public static int getConfig(String key, int defaultValue) {
        return MyApplication.getInstance().getSharedPreferences("config", Context.MODE_PRIVATE).getInt(key, defaultValue);
    }

    public static void putBoolean(String key, boolean value) {
        MyApplication.getInstance().getSharedPreferences("config", Context.MODE_PRIVATE).edit().putBoolean(key, value).apply();
    }

    public static boolean getBoolean(String key, boolean defaultValue) {
        return MyApplication.getInstance().getSharedPreferences("config", Context.MODE_PRIVATE).getBoolean(key, defaultValue);
    }

//    public static void setLanguagePreference(String languageCode) {
//        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MyApplication.getInstance());
//        SharedPreferences.Editor editor = preferences.edit();
//        editor.putString("language_code", languageCode);
//        editor.apply();
//    }
//
//
//    public static String getLanguagePreference() {
//
//        Locale defaultLocale = Locale.getDefault();
//        String languageCode = defaultLocale.getLanguage();
//        Log.d(TAG, "系统默认语言代码: " + languageCode);
//
//        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MyApplication.getInstance());
//        return preferences.getString("language_code", languageCode);
//    }


}
